[damned-lies] Add Information (error) object in sample_data fixture
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Add Information (error) object in sample_data fixture
- Date: Thu, 17 Feb 2011 21:17:22 +0000 (UTC)
commit c0f3edb443440e981b60e69d754e79602c79f1ab
Author: Claude Paroz <claude 2xlibre net>
Date: Thu Feb 17 22:17:10 2011 +0100
Add Information (error) object in sample_data fixture
stats/fixtures/sample_data.json | 101 ++++++++++++++++++---------------
stats/models.py | 4 +-
stats/tests/fixture_factory.py | 121 ++++++++++++++++-----------------------
3 files changed, 107 insertions(+), 119 deletions(-)
---
diff --git a/stats/fixtures/sample_data.json b/stats/fixtures/sample_data.json
index b0271a4..05d3886 100644
--- a/stats/fixtures/sample_data.json
+++ b/stats/fixtures/sample_data.json
@@ -9,12 +9,12 @@
"is_active": true,
"is_superuser": false,
"is_staff": false,
- "last_login": "2010-11-23 12:08:32",
+ "last_login": "2011-02-17 22:15:33",
"groups": [],
"user_permissions": [],
"password": "!",
"email": "bob example org",
- "date_joined": "2010-11-23 12:08:32"
+ "date_joined": "2011-02-17 22:15:33"
}
},
{
@@ -27,12 +27,12 @@
"is_active": true,
"is_superuser": false,
"is_staff": false,
- "last_login": "2010-11-23 12:08:32",
+ "last_login": "2011-02-17 22:15:33",
"groups": [],
"user_permissions": [],
"password": "!",
"email": "coord example org",
- "date_joined": "2010-11-23 12:08:32"
+ "date_joined": "2011-02-17 22:15:33"
}
},
{
@@ -45,44 +45,44 @@
"is_active": true,
"is_superuser": false,
"is_staff": false,
- "last_login": "2010-11-23 12:08:32",
+ "last_login": "2011-02-17 22:15:33",
"groups": [],
"user_permissions": [],
"password": "!",
"email": "alessio example org",
- "date_joined": "2010-11-23 12:08:32"
+ "date_joined": "2011-02-17 22:15:33"
}
},
{
- "pk": 2,
+ "pk": 4,
"model": "people.person",
"fields": {
"bugzilla_account": null,
"groups": [],
"image": null,
"activation_key": null,
- "irc_nick": "bobby",
- "svn_account": "bob1",
+ "irc_nick": null,
+ "svn_account": null,
"webpage_url": null,
"user_permissions": []
}
},
{
- "pk": 3,
+ "pk": 2,
"model": "people.person",
"fields": {
"bugzilla_account": null,
"groups": [],
"image": null,
"activation_key": null,
- "irc_nick": null,
- "svn_account": "coord_fr",
+ "irc_nick": "bobby",
+ "svn_account": "bob1",
"webpage_url": null,
"user_permissions": []
}
},
{
- "pk": 4,
+ "pk": 3,
"model": "people.person",
"fields": {
"bugzilla_account": null,
@@ -90,12 +90,22 @@
"image": null,
"activation_key": null,
"irc_nick": null,
- "svn_account": null,
+ "svn_account": "coord_fr",
"webpage_url": null,
"user_permissions": []
}
},
{
+ "pk": 1,
+ "model": "languages.language",
+ "fields": {
+ "locale": "en",
+ "plurals": "nplurals=2; plural=(n != 1)",
+ "name": "en",
+ "team": null
+ }
+ },
+ {
"pk": 2,
"model": "languages.language",
"fields": {
@@ -117,16 +127,6 @@
},
{
"pk": 1,
- "model": "languages.language",
- "fields": {
- "locale": "en",
- "plurals": "nplurals=2; plural=(n != 1)",
- "name": "en",
- "team": null
- }
- },
- {
- "pk": 1,
"model": "teams.team",
"fields": {
"mailing_list_subscribe": "http://www.traduc.org/mailman/listinfo/gnomefr",
@@ -433,7 +433,7 @@
"untranslated": 47,
"translated": 0,
"branch": 1,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -447,7 +447,7 @@
"untranslated": 0,
"translated": 47,
"branch": 1,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -461,7 +461,7 @@
"untranslated": 7,
"translated": 30,
"branch": 1,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 10
}
},
@@ -475,7 +475,7 @@
"untranslated": 20,
"translated": 0,
"branch": 1,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -489,7 +489,7 @@
"untranslated": 0,
"translated": 20,
"branch": 1,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -503,7 +503,7 @@
"untranslated": 0,
"translated": 20,
"branch": 1,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -517,7 +517,7 @@
"untranslated": 136,
"translated": 0,
"branch": 2,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -531,7 +531,7 @@
"untranslated": 0,
"translated": 136,
"branch": 2,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -545,7 +545,7 @@
"untranslated": 6,
"translated": 130,
"branch": 2,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -559,7 +559,7 @@
"untranslated": 259,
"translated": 0,
"branch": 2,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -573,7 +573,7 @@
"untranslated": 259,
"translated": 0,
"branch": 2,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -587,7 +587,7 @@
"untranslated": 0,
"translated": 259,
"branch": 2,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -601,7 +601,7 @@
"untranslated": 149,
"translated": 0,
"branch": 3,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -615,7 +615,7 @@
"untranslated": 0,
"translated": 255,
"branch": 3,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 4
}
},
@@ -629,7 +629,7 @@
"untranslated": 0,
"translated": 259,
"branch": 3,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -643,7 +643,7 @@
"untranslated": 259,
"translated": 0,
"branch": 3,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -657,7 +657,7 @@
"untranslated": 259,
"translated": 0,
"branch": 3,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -671,7 +671,7 @@
"untranslated": 0,
"translated": 259,
"branch": 3,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -685,7 +685,7 @@
"untranslated": 626,
"translated": 0,
"branch": 4,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 0
}
},
@@ -699,7 +699,7 @@
"untranslated": 2,
"translated": 598,
"branch": 4,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 20
}
},
@@ -713,8 +713,17 @@
"untranslated": 0,
"translated": 620,
"branch": 4,
- "date": "2010-11-23 12:08:32",
+ "date": "2011-02-17 22:15:33",
"fuzzy": 6
}
+ },
+ {
+ "pk": 1,
+ "model": "stats.information",
+ "fields": {
+ "statistics": 13,
+ "type": "error",
+ "description": "Error regenerating POT file for zenity:\n<pre>intltool-update -g 'zenity' -p\nERROR: xgettext failed to generate PO template file.</pre>"
+ }
}
-]
+]
\ No newline at end of file
diff --git a/stats/models.py b/stats/models.py
index d7f7a4b..9937724 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -81,8 +81,8 @@ class Module(models.Model):
def get_absolute_url(self):
return ('stats.views.module', [self.name])
- def save(self, force_insert=False, force_update=False):
- super(Module, self).save(force_insert, force_update)
+ def save(self, *args, **kwargs):
+ super(Module, self).save(*args, **kwargs)
#FIXME: delete and recreate branch if vcs_root changed?
def get_description(self):
diff --git a/stats/tests/fixture_factory.py b/stats/tests/fixture_factory.py
index 83996fc..ceffcdb 100644
--- a/stats/tests/fixture_factory.py
+++ b/stats/tests/fixture_factory.py
@@ -6,7 +6,7 @@ from django.test import TestCase
from languages.models import Language
from teams.models import Team, Role
from people.models import Person
-from stats.models import Module, Domain, Branch, Release, Category, Statistics
+from stats.models import Module, Domain, Branch, Release, Category, Statistics, Information
class FixtureFactory(TestCase):
""" Fake Test case to create fixture.
@@ -16,65 +16,52 @@ class FixtureFactory(TestCase):
def make_fixture(self):
# Creating models: Teams
- t1 = Team(name='fr', description="French",
+ t1 = Team.objects.create(name='fr', description="French",
webpage_url="http://gnomefr.traduc.org/",
mailing_list="gnomefr traduc org",
mailing_list_subscribe="http://www.traduc.org/mailman/listinfo/gnomefr",
presentation="Here can come any custom description for a team")
- t1.save()
- t2 = Team(name='it', description="Italian",
+ t2 = Team.objects.create(name='it', description="Italian",
webpage_url="http://www.it.gnome.org/")
- t2.save()
# Creating models: Languages
- l_en = Language(name='en', locale='en', plurals="nplurals=2; plural=(n != 1)")
- l_en.save()
- l_fr = Language(name='French', locale='fr', plurals="nplurals=2; plural=(n > 1)",
+ l_en = Language.objects.create(name='en', locale='en', plurals="nplurals=2; plural=(n != 1)")
+ l_fr = Language.objects.create(name='French', locale='fr', plurals="nplurals=2; plural=(n > 1)",
team=t1)
- l_fr.save()
- l_it = Language(name='Italian', locale='it', plurals="nplurals=2; plural=(n != 1)",
+ l_it = Language.objects.create(name='Italian', locale='it', plurals="nplurals=2; plural=(n != 1)",
team=t2)
- l_it.save()
# Creating models: Persons/Roles
p0 = Person.objects.create(username='admin1') # Fake person (deleted below), just not to use pk=1 for user
- p1 = Person(first_name='Robert', last_name='Translator',
+ p1 = Person.objects.create(first_name='Robert', last_name='Translator',
email='bob example org', username='bob', irc_nick='bobby',
svn_account='bob1')
- p1.save()
p1.set_password('bob')
- r1 = Role(team=t1, person=p1, role='translator')
- r1.save()
- p2 = Person(first_name='John', last_name='Coordinator',
+ r1 = Role.objects.create(team=t1, person=p1, role='translator')
+ p2 = Person.objects.create(first_name='John', last_name='Coordinator',
email='coord example org', username='coord', svn_account='coord_fr')
- p2.save()
p2.set_password('coord')
- r2 = Role(team=t1, person=p2, role='coordinator')
- r2.save()
- p3 = Person(first_name='Alessio', last_name='Reviewer',
+ r2 = Role.objects.create(team=t1, person=p2, role='coordinator')
+ p3 = Person.objects.create(first_name='Alessio', last_name='Reviewer',
email='alessio example org', username='alessio')
- p3.save()
p1.set_password('alessio')
- r3 = Role(team=t2, person=p3, role='reviewer')
- r3.save()
+ r3 = Role.objects.create(team=t2, person=p3, role='reviewer')
p0.delete()
# Creating models: Modules
- gnome_hello = Module(name="gnome-hello", vcs_type="git",
+ gnome_hello = Module.objects.create(name="gnome-hello", vcs_type="git",
vcs_root="git://git.gnome.org/gnome-hello",
vcs_web="http://git.gnome.org/browse/gnome-hello/",
bugs_base="http://bugzilla.gnome.org",
bugs_product="gnome-hello",
bugs_component="test")
- gnome_hello.save()
- zenity = Module(name="zenity", vcs_type="git",
+ zenity = Module.objects.create(name="zenity", vcs_type="git",
vcs_root="git://git.gnome.org/zenity",
vcs_web="http://git.gnome.org/browse/zenity/",
bugs_base="http://bugzilla.gnome.org",
bugs_product="zenity",
bugs_component="general")
- zenity.save()
- s_m_i = Module(name="shared-mime-info", vcs_type="git",
+ s_m_i = Module.objects.create(name="shared-mime-info", vcs_type="git",
description="Shared MIME Info",
vcs_root="git://anongit.freedesktop.org/xdg/shared-mime-info",
vcs_web="http://cgit.freedesktop.org/xdg/shared-mime-info/",
@@ -83,15 +70,12 @@ class FixtureFactory(TestCase):
bugs_component="general",
comment="This is not a GNOME-specific module. Please submit your translation " \
"through the <a href=\"http://www.transifex.net/projects/p/shared-mime-info/c/default/\">Transifex platform</a>.")
- s_m_i.save()
# Creating models: Domains
dom = {}
for mod in (gnome_hello, zenity, s_m_i):
- dom['%s-ui' % mod.name] = Domain(module=mod, name='po', description='UI Translations', dtype='ui', directory='po')
- dom['%s-ui' % mod.name].save()
- dom['%s-doc' % mod.name] = Domain(module=mod, name='help', description='User Guide', dtype='doc', directory='help')
- dom['%s-doc' % mod.name].save()
+ dom['%s-ui' % mod.name] = Domain.objects.create(module=mod, name='po', description='UI Translations', dtype='ui', directory='po')
+ dom['%s-doc' % mod.name] = Domain.objects.create(module=mod, name='help', description='User Guide', dtype='doc', directory='help')
# Creating models: Branches
Branch.checkout_on_creation = False
@@ -105,56 +89,51 @@ class FixtureFactory(TestCase):
b4.save(update_statistics=False)
# Creating models: Releases/Categories
- rel1 = Release(name='gnome-2-30', status='official',
+ rel1 = Release.objects.create(name='gnome-2-30', status='official',
description='GNOME 2.30 (stable)',
string_frozen=True)
- rel1.save()
- rel2 = Release(name='gnome-dev', status='official',
+ rel2 = Release.objects.create(name='gnome-dev', status='official',
description='GNOME in Development',
string_frozen=False)
- rel2.save()
- rel3 = Release(name='freedesktop-org', status='xternal',
+ rel3 = Release.objects.create(name='freedesktop-org', status='xternal',
description='freedesktop.org (non-GNOME)',
string_frozen=False)
- rel3.save()
- cat1 = Category(release=rel1, branch=b1, name='desktop')
- cat1.save()
- cat2 = Category(release=rel2, branch=b1, name='desktop')
- cat2.save()
- cat3 = Category(release=rel1, branch=b2, name='desktop')
- cat3.save()
- cat4 = Category(release=rel3, branch=b4, name='desktop')
- cat4.save()
+ cat1 = Category.objects.create(release=rel1, branch=b1, name='desktop')
+ cat2 = Category.objects.create(release=rel2, branch=b1, name='desktop')
+ cat3 = Category.objects.create(release=rel1, branch=b2, name='desktop')
+ cat4 = Category.objects.create(release=rel3, branch=b4, name='desktop')
# Creating models: Statistics
# gnome-hello ui, gnome-hello doc (POT, fr, it)
- stats = []
- stats.append(Statistics(branch=b1, domain=dom['gnome-hello-ui'], language=None, untranslated=47))
- stats.append(Statistics(branch=b1, domain=dom['gnome-hello-ui'], language=l_fr, translated=47))
- stats.append(Statistics(branch=b1, domain=dom['gnome-hello-ui'], language=l_it, translated=30, fuzzy=10, untranslated=7))
- stats.append(Statistics(branch=b1, domain=dom['gnome-hello-doc'], language=None, untranslated=20, num_figures=1))
- stats.append(Statistics(branch=b1, domain=dom['gnome-hello-doc'], language=l_fr, translated=20))
- stats.append(Statistics(branch=b1, domain=dom['gnome-hello-doc'], language=l_it, translated=20))
+ Statistics.objects.create(branch=b1, domain=dom['gnome-hello-ui'], language=None, untranslated=47)
+ Statistics.objects.create(branch=b1, domain=dom['gnome-hello-ui'], language=l_fr, translated=47)
+ Statistics.objects.create(branch=b1, domain=dom['gnome-hello-ui'], language=l_it, translated=30, fuzzy=10, untranslated=7)
+ Statistics.objects.create(branch=b1, domain=dom['gnome-hello-doc'], language=None, untranslated=20, num_figures=1)
+ Statistics.objects.create(branch=b1, domain=dom['gnome-hello-doc'], language=l_fr, translated=20)
+ Statistics.objects.create(branch=b1, domain=dom['gnome-hello-doc'], language=l_it, translated=20)
# zenity ui 2.30, zenity doc 2.30, zenity ui master, zenity doc master (POT, fr, it)
- stats.append(Statistics(branch=b2, domain=dom['zenity-ui'], language=None, untranslated=136))
- stats.append(Statistics(branch=b2, domain=dom['zenity-ui'], language=l_fr, translated=136))
- stats.append(Statistics(branch=b2, domain=dom['zenity-ui'], language=l_it, translated=130, untranslated=6))
- stats.append(Statistics(branch=b2, domain=dom['zenity-doc'], language=None, untranslated=259, num_figures=11))
- stats.append(Statistics(branch=b2, domain=dom['zenity-doc'], language=l_fr, untranslated=259))
- stats.append(Statistics(branch=b2, domain=dom['zenity-doc'], language=l_it, translated=259))
- stats.append(Statistics(branch=b3, domain=dom['zenity-ui'], language=None, untranslated=149))
- stats.append(Statistics(branch=b3, domain=dom['zenity-ui'], language=l_fr, translated=255, fuzzy=4))
- stats.append(Statistics(branch=b3, domain=dom['zenity-ui'], language=l_it, translated=259))
- stats.append(Statistics(branch=b3, domain=dom['zenity-doc'], language=None, untranslated=259, num_figures=11))
- stats.append(Statistics(branch=b3, domain=dom['zenity-doc'], language=l_fr, untranslated=259))
- stats.append(Statistics(branch=b3, domain=dom['zenity-doc'], language=l_it, translated=259))
+ Statistics.objects.create(branch=b2, domain=dom['zenity-ui'], language=None, untranslated=136)
+ Statistics.objects.create(branch=b2, domain=dom['zenity-ui'], language=l_fr, translated=136)
+ Statistics.objects.create(branch=b2, domain=dom['zenity-ui'], language=l_it, translated=130, untranslated=6)
+ Statistics.objects.create(branch=b2, domain=dom['zenity-doc'], language=None, untranslated=259, num_figures=11)
+ Statistics.objects.create(branch=b2, domain=dom['zenity-doc'], language=l_fr, untranslated=259)
+ Statistics.objects.create(branch=b2, domain=dom['zenity-doc'], language=l_it, translated=259)
+ stat1 = Statistics.objects.create(branch=b3, domain=dom['zenity-ui'], language=None, untranslated=149)
+ Statistics.objects.create(branch=b3, domain=dom['zenity-ui'], language=l_fr, translated=255, fuzzy=4)
+ Statistics.objects.create(branch=b3, domain=dom['zenity-ui'], language=l_it, translated=259)
+ Statistics.objects.create(branch=b3, domain=dom['zenity-doc'], language=None, untranslated=259, num_figures=11)
+ Statistics.objects.create(branch=b3, domain=dom['zenity-doc'], language=l_fr, untranslated=259)
+ Statistics.objects.create(branch=b3, domain=dom['zenity-doc'], language=l_it, translated=259)
# shared-mime-info ui (POT, fr, it)
- stats.append(Statistics(branch=b4, domain=dom['shared-mime-info-ui'], language=None, untranslated=626))
- stats.append(Statistics(branch=b4, domain=dom['shared-mime-info-ui'], language=l_fr, translated=598, fuzzy=20, untranslated=2))
- stats.append(Statistics(branch=b4, domain=dom['shared-mime-info-ui'], language=l_it, translated=620, fuzzy=6))
- for st in stats:
- st.save()
+ Statistics.objects.create(branch=b4, domain=dom['shared-mime-info-ui'], language=None, untranslated=626)
+ Statistics.objects.create(branch=b4, domain=dom['shared-mime-info-ui'], language=l_fr, translated=598, fuzzy=20, untranslated=2)
+ Statistics.objects.create(branch=b4, domain=dom['shared-mime-info-ui'], language=l_it, translated=620, fuzzy=6)
+
+ # Example of error
+ stat1.information_set.add(Information(
+ type='error',
+ description="Error regenerating POT file for zenity:\n<pre>intltool-update -g 'zenity' -p\nERROR: xgettext failed to generate PO template file.</pre>"))
# Output fixture
data = Dumpdata().handle(*['auth.User', 'people', 'languages', 'teams', 'stats'],
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]