Skip to content
Browse files

fixed some failing tests

  • Loading branch information...
1 parent 7807427 commit 8e5973e1b8520583abc8d0507151aecf641cdfd4 @camd camd committed Mar 21, 2013
View
3 moztrap/model/library/models.py
@@ -117,9 +117,6 @@ def save(self, *args, **kwargs):
skip_set_latest = kwargs.pop("skip_set_latest", False)
skip_sync_name = kwargs.pop("skip_sync_name", False)
super(CaseVersion, self).save(*args, **kwargs)
-
- print("CV is \n'{0}'\nfor {1}".format(self.name, self.productversion))
-
if not skip_set_latest:
self.case.set_latest_version(update_instance=self)
View
2 tests/case/api/crud.py
@@ -478,7 +478,7 @@ def test_update_without_fk(self):
fixture1 = self.factory
for fk in self.read_create_fields:
- mozlogger.info('test_update_without_fk %s' % fk)
+ mozlogger.info('test_update_without_fk {0}'.format(fk))
fields = self.backend_data(fixture1)
fields = self.manipulate_edit_data(fixture1, fields)
View
70 tests/model/library/test_importer.py
@@ -156,7 +156,7 @@ def test_create_two_caseversions_same_user(self):
Two caseversions that both use the same user. Test that import caches
the user and doesn't have to query for it a second time.
- Expect 17 queries for this import:
+ Expect 19 queries for this import:
Query 1: Ensure this caseversion does not already exist for this
productversion::
@@ -240,7 +240,32 @@ def test_create_two_caseversions_same_user(self):
= Foo, `description` = , `latest` = True, `envs_narrowed` = False
WHERE `library_caseversion`.`id` = 10
- Query 9: Add the new step to the caseversion::
+ Query 9: During save, check if there are other caseversions for this
+ case to sync names.
+ SELECT `library_caseversion`.`id`, `library_caseversion`
+ .`created_on`,
+ `library_caseversion`.`created_by_id`, `library_caseversion`
+ .`modified_on`,
+ `library_caseversion`.`modified_by_id`, `library_caseversion`
+ .`deleted_on`,
+ `library_caseversion`.`deleted_by_id`, `library_caseversion`
+ .`cc_version`,
+ `library_caseversion`.`status`, `library_caseversion`
+ .`productversion_id`,
+ `library_caseversion`.`case_id`, `library_caseversion`.`name`,
+ `library_caseversion`.`description`, `library_caseversion`
+ .`latest`,
+ `library_caseversion`.`envs_narrowed` FROM `library_caseversion`
+ INNER JOIN
+ `core_productversion` ON (`library_caseversion`
+ .`productversion_id` =
+ `core_productversion`.`id`) WHERE (`library_caseversion`
+ .`deleted_on` IS
+ NULL AND `library_caseversion`.`case_id` = 1 ) ORDER BY
+ `library_caseversion`.`case_id` ASC,
+ `core_productversion`.`order` ASC
+
+ Query 10: Add the new step to the caseversion::
INSERT INTO `library_casestep` (`created_on`, `created_by_id`,
`modified_on`, `modified_by_id`, `deleted_on`, `deleted_by_id`,
@@ -250,7 +275,7 @@ def test_create_two_caseversions_same_user(self):
Transaction: RELEASE SAVEPOINT s140735243669888_x1
- Query 10: Ensure the second caseversion with this name and pv doesn't
+ Query 11: Ensure the second caseversion with this name and pv doesn't
exist::
SELECT (1) AS `a` FROM `library_caseversion` WHERE
@@ -263,14 +288,14 @@ def test_create_two_caseversions_same_user(self):
**NOTE: We didn't have to search for the user again, since it was
cached**
- Query 11: Create the second new case::
+ Query 12: Create the second new case::
INSERT INTO `library_case` (`created_on`, `created_by_id`,
`modified_on`, `modified_by_id`, `deleted_on`, `deleted_by_id`,
`product_id`) VALUES (2012-03-07 19:35:34, None, 2012-03-07
19:35:34, None, None, None, 12)
- Queries 12-16: Create the second new caseversion::
+ Queries 13-17: Create the second new caseversion::
INSERT INTO `library_caseversion` (`created_on`, `created_by_id`,
`modified_on`, `modified_by_id`, `deleted_on`, `deleted_by_id`,
@@ -326,7 +351,32 @@ def test_create_two_caseversions_same_user(self):
True, `envs_narrowed` = False WHERE `library_caseversion`.`id` =
11
- Query 17: Add the step to the second caseversion::
+ Query 18: Check for other caseversions for the same case to sync names
+
+ SELECT `library_caseversion`.`id`, `library_caseversion`
+ .`created_on`,
+ `library_caseversion`.`created_by_id`, `library_caseversion`
+ .`modified_on`,
+ `library_caseversion`.`modified_by_id`, `library_caseversion`
+ .`deleted_on`,
+ `library_caseversion`.`deleted_by_id`, `library_caseversion`
+ .`cc_version`,
+ `library_caseversion`.`status`, `library_caseversion`
+ .`productversion_id`,
+ `library_caseversion`.`case_id`, `library_caseversion`.`name`,
+ `library_caseversion`.`description`, `library_caseversion`
+ .`latest`,
+ `library_caseversion`.`envs_narrowed` FROM `library_caseversion`
+ INNER JOIN
+ `core_productversion` ON (`library_caseversion`
+ .`productversion_id` =
+ `core_productversion`.`id`) WHERE (`library_caseversion`
+ .`deleted_on` IS
+ NULL AND `library_caseversion`.`case_id` = 2 ) ORDER BY
+ `library_caseversion`.`case_id` ASC,
+ `core_productversion`.`order` ASC
+
+ Query 19: Add the step to the second caseversion::
INSERT INTO `library_casestep` (`created_on`, `created_by_id`,
`modified_on`, `modified_by_id`, `deleted_on`, `deleted_by_id`,
@@ -338,7 +388,7 @@ def test_create_two_caseversions_same_user(self):
Note: Django 1.4 now logs transaction points in the connection.queries
- EXPECT: 17 Queries + 4 Transaction actions = 21 queries.
+ EXPECT: 19 Queries + 4 Transaction actions = 23 queries.
To re-capture this query list, use a block like this in place
of the "with self.assertNumQueries..." block::
@@ -351,7 +401,7 @@ def test_create_two_caseversions_same_user(self):
connection.queries = []
result = self.import_data(case_data)
- self.assertFalse(json.dumps(connection.queries, indent=4))
+ print(json.dumps(connection.queries, indent=4))
settings.DEBUG = False
"""
@@ -375,7 +425,7 @@ def test_create_two_caseversions_same_user(self):
}
# Test code as normal
- with self.assertNumQueries(21):
+ with self.assertNumQueries(23):
result = self.import_data(case_data)
cv1 = self.model.CaseVersion.objects.get(name="Foo")
@@ -436,7 +486,7 @@ def test_create_caseversion_existing_tag(self):
def test_create_caseversion_existing_tag_different_case(self):
- """A caseversion that uses an existing product tag with different case"""
+ """A caseversion that uses an existing product tag with diff case"""
# need a tag to exist, so the import can find it.
tag = self.model.Tag.objects.create(
View
13 tests/view/lists/test_cases.py
@@ -2,7 +2,6 @@
Tests for test case queryset-filtering by ID and with optional ID prefix.
"""
-from sets import Set
from tests import case
from moztrap.view.lists.cases import PrefixIDFilter
@@ -72,8 +71,8 @@ def test_id_and_prefix_from_different_cases_gets_both(self):
res = self.filter([u"pre", unicode(td["cv2"].case.id)])
self.assertEqual(
- Set([x.name for x in res.all()]),
- Set(["CV 1", "CV 2"]),
+ set([x.name for x in res.all()]),
+ set(["CV 1", "CV 2"]),
)
@@ -93,8 +92,8 @@ def test_cases_different_prefix_return_both(self):
res = self.filter([u"pre", u"moz"])
self.assertEqual(
- Set([x.name for x in res.all()]),
- Set(["CV 1", "CV 3", "CV 4"]),
+ set([x.name for x in res.all()]),
+ set(["CV 1", "CV 3", "CV 4"]),
)
@@ -104,6 +103,6 @@ def test_cases_same_prefix_return_both(self):
res = self.filter([u"moz"])
self.assertEqual(
- Set([x.name for x in res.all()]),
- Set(["CV 3", "CV 4"]),
+ set([x.name for x in res.all()]),
+ set(["CV 3", "CV 4"]),
)
View
19 tests/view/manage/cases/test_views.py
@@ -43,18 +43,16 @@ def test_create_link(self):
def test_lists_all_versions(self):
"""Lists all versions of each case."""
- cv = self.F.CaseVersionFactory.create(
- name="Old Version", productversion__version="1.0")
- self.F.CaseVersionFactory.create(
- name="Latest Version",
+ cv = self.F.CaseVersionFactory.create(productversion__version="1.0")
+ cv2 = self.F.CaseVersionFactory.create(
case=cv.case,
productversion__product=cv.productversion.product,
productversion__version="2.0")
res = self.get()
- self.assertInList(res, "Old Version")
- self.assertInList(res, "Latest Version")
+ self.assertIdInList(res, "caseversion-id-{0}".format(cv.id))
+ self.assertIdInList(res, "caseversion-id-{0}".format(cv2.id))
def test_filter_by_status(self):
@@ -125,17 +123,16 @@ def test_filter_by_product(self):
def test_filter_by_productversion(self):
"""Can filter by product version; no implicit filter by latest."""
- cv = self.F.CaseVersionFactory.create(name="Case 1")
- self.F.CaseVersionFactory.create(
- name="Case 2",
+ cv = self.F.CaseVersionFactory.create()
+ cv2 = self.F.CaseVersionFactory.create(
case=cv.case,
productversion__product=cv.productversion.product,
productversion__version="2.0")
res = self.get(params={"filter-productversion": cv.productversion.id})
- self.assertInList(res, "Case 1")
- self.assertNotInList(res, "Case 2")
+ self.assertIdInList(res, "caseversion-id-{0}".format(cv.id))
+ self.assertIdNotInList(res, "caseversion-id-{0}".format(cv2.id))
def test_filter_by_step_instruction(self):
View
9 tests/view/results/runcaseversions/test_views.py
@@ -98,20 +98,19 @@ def test_filter_by_product(self):
def test_filter_by_productversion(self):
"""Can filter by product version; no implicit filter by latest."""
- rcv = self.F.RunCaseVersionFactory.create(caseversion__name="Case 1")
+ rcv = self.F.RunCaseVersionFactory.create()
other_pv = self.F.ProductVersionFactory(
product=rcv.caseversion.productversion.product, version="2.0")
- self.F.RunCaseVersionFactory.create(
- caseversion__name="Case 2",
+ rcv2 = self.F.RunCaseVersionFactory.create(
caseversion__case=rcv.caseversion.case,
caseversion__productversion=other_pv,
run__productversion=other_pv)
res = self.get(
params={"filter-productversion": rcv.caseversion.productversion.id})
- self.assertInList(res, "Case 1")
- self.assertNotInList(res, "Case 2")
+ self.assertIdInList(res, "runcaseversion-id-{0}".format(rcv.id))
+ self.assertIdNotInList(res, "runcaseversion-id-{0}".format(rcv2.id))
def test_filter_by_step_instruction(self):

0 comments on commit 8e5973e

Please sign in to comment.
Something went wrong with that request. Please try again.