Ejemplo n.º 1
0
    def test_value_two_platforms(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform',
                                                    'Some Platform')
        other_platform = Platform.create_if_possible('other-platform',
                                                     'Other Platform')
        some_test = Test.update_or_insert('some-test', some_branch,
                                          some_platform)

        self._assert_single_test(ManifestJSONGenerator().value(), some_branch,
                                 some_platform, some_test)

        some_test = Test.update_or_insert('some-test', some_branch,
                                          other_platform)
        self.assertEqualUnorderedList(
            some_test.platforms,
            [some_platform.key(), other_platform.key()])

        value = ManifestJSONGenerator().value()
        expected_platform_ids = [some_platform.id, other_platform.id]
        self.assertEqualUnorderedList(value.keys(),
                                      ['branchMap', 'platformMap', 'testMap'])
        self.assertEqualUnorderedList(
            value['branchMap'], {
                some_branch.id: {
                    'name': some_branch.name,
                    'testIds': [some_test.id],
                    'platformIds': expected_platform_ids
                }
            })
        self.assertEqual(
            value['platformMap'], {
                some_platform.id: {
                    'name': some_platform.name,
                    'branchIds': [some_branch.id],
                    'testIds': [some_test.id]
                },
                other_platform.id: {
                    'name': other_platform.name,
                    'branchIds': [some_branch.id],
                    'testIds': [some_test.id]
                }
            })
        self.assertEqual(
            value['testMap'], {
                some_test.id: {
                    'name': some_test.name,
                    'branchIds': [some_branch.id],
                    'platformIds': expected_platform_ids
                }
            })
Ejemplo n.º 2
0
    def test_value_single_platform(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform',
                                                    'Some Platform')
        self.assertEqual(ManifestJSONGenerator().value(), {
            'branchMap': {},
            'platformMap': {},
            'testMap': {}
        })

        some_test = Test.update_or_insert('some-test', some_branch,
                                          some_platform)
        self._assert_single_test(ManifestJSONGenerator().value(), some_branch,
                                 some_platform, some_test)
Ejemplo n.º 3
0
 def test_value_no_plaforms(self):
     some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
     self.assertEqual(ManifestJSONGenerator().value(), {
         'branchMap': {},
         'platformMap': {},
         'testMap': {}
     })
Ejemplo n.º 4
0
 def test_value_no_branch(self):
     self.assertThereIsNoInstanceOf(Branch)
     self.assertEqual(ManifestJSONGenerator().value(), {
         'branchMap': {},
         'platformMap': {},
         'testMap': {}
     })
Ejemplo n.º 5
0
    def test_value_with_hidden_platform_and_test(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform',
                                                    'Some Platform')
        hidden_platform = Platform.create_if_possible('hidden-platform',
                                                      'Hidden Platform')
        hidden_platform.hidden = True
        hidden_platform.put()

        Test.update_or_insert('some-test', some_branch, some_platform)
        some_test = Test.update_or_insert('some-test', some_branch,
                                          hidden_platform)

        Test.update_or_insert('hidden-test', some_branch, some_platform)
        hidden_test = Test.update_or_insert('hidden-test', some_branch,
                                            hidden_platform)
        hidden_test.hidden = True
        hidden_test.put()

        value = ManifestJSONGenerator().value()
        expected_test_ids = []
        self.assertEqualUnorderedList(value.keys(),
                                      ['branchMap', 'platformMap', 'testMap'])
        self.assertEqual(
            value['branchMap'], {
                some_branch.id: {
                    'name': some_branch.name,
                    'testIds': [some_test.id],
                    'platformIds': [some_platform.id]
                }
            })
        self.assertEqual(
            value['platformMap'], {
                some_platform.id: {
                    'name': some_platform.name,
                    'branchIds': [some_branch.id],
                    'testIds': [some_test.id]
                }
            })
        self.assertEqual(
            value['testMap'], {
                some_test.id: {
                    'name': some_test.name,
                    'branchIds': [some_branch.id],
                    'platformIds': [some_platform.id]
                }
            })
Ejemplo n.º 6
0
    def test_value_two_tests(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)

        self._assert_single_test(ManifestJSONGenerator().value(), some_branch, some_platform, some_test)

        other_test = Test.update_or_insert('other-test', some_branch, some_platform)

        value = ManifestJSONGenerator().value()
        expected_test_ids = [some_test.id, other_test.id]
        self.assertEqualUnorderedList(value.keys(), ['branchMap', 'platformMap', 'testMap'])
        self.assertEqualUnorderedList(value['branchMap'],
            {some_branch.id: {'name': some_branch.name, 'testIds': expected_test_ids, 'platformIds': [some_platform.id]}})
        self.assertEqual(value['platformMap'],
            {some_platform.id: {'name': some_platform.name, 'branchIds': [some_branch.id], 'testIds': expected_test_ids}})
        self.assertEqual(value['testMap'],
            {some_test.id: {'name': some_test.name, 'branchIds': [some_branch.id], 'platformIds': [some_platform.id]},
            other_test.id: {'name': other_test.name, 'branchIds': [some_branch.id], 'platformIds': [some_platform.id]}})
Ejemplo n.º 7
0
    def test_value_with_hidden_platform_and_test(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        hidden_platform = Platform.create_if_possible('hidden-platform', 'Hidden Platform')
        hidden_platform.hidden = True
        hidden_platform.put()

        Test.update_or_insert('some-test', some_branch, some_platform)
        some_test = Test.update_or_insert('some-test', some_branch, hidden_platform)

        Test.update_or_insert('hidden-test', some_branch, some_platform)
        hidden_test = Test.update_or_insert('hidden-test', some_branch, hidden_platform)
        hidden_test.hidden = True
        hidden_test.put()

        value = ManifestJSONGenerator().value()
        expected_test_ids = []
        self.assertEqualUnorderedList(value.keys(), ['branchMap', 'platformMap', 'testMap'])
        self.assertEqual(value['branchMap'],
            {some_branch.id: {'name': some_branch.name, 'testIds': [some_test.id], 'platformIds': [some_platform.id]}})
        self.assertEqual(value['platformMap'],
            {some_platform.id: {'name': some_platform.name, 'branchIds': [some_branch.id], 'testIds': [some_test.id]}})
        self.assertEqual(value['testMap'],
            {some_test.id: {'name': some_test.name, 'branchIds': [some_branch.id], 'platformIds': [some_platform.id]}})
Ejemplo n.º 8
0
 def post(self):
     self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
     PersistentCache.set_cache('manifest',
                               ManifestJSONGenerator().to_json())
     self.response.out.write('OK')