Example #1
0
 def test_all_templets(self):
     templates = get_all_templates()
     self.assertIsNotNone(templates)
     self.assertTrue(len(templates) > 0)
     self.assertTrue(templates[0].otype == 'template')
     table = self.make_template_table(templates)
     probe = table['global_Electropolishing']
     self.assertIsNotNone(probe)
     self.assertTrue(probe.otype == 'template')
Example #2
0
 def test_non_admin_user_cannot_update_standard_template(self):
     templates = get_all_templates()
     self.assertIsNotNone(templates)
     self.assertTrue(len(templates) > 0)
     self.assertTrue(templates[0].otype == 'template')
     table = self.make_template_table(templates)
     template_id = 'global_As Measured'
     template = table[template_id]
     self.assertIsNotNone(template)
     self.assertEqual(template.id, template_id)
     update_data = template.input_data
     update_data["does_transform"] = True
     self.assertNotEqual(update_data['owner'], '*****@*****.**')
     update_data.pop('id')
     update_data.pop('owner')
     with pytest.raises(Exception):
         _update_template(template.id, update_data)
Example #3
0
    def template_admin_can_update_any_template(self):
        another_user_id = '*****@*****.**'
        another_user_key = 'bogus-for-template'

        users = get_all_users()
        user = None
        for probe in users:
            if probe.id == another_user_id:
                user = probe
        self.assertIsNotNone(user)

        self._set_up_remote_for(another_user_key)

        templates = get_all_templates()
        self.assertIsNotNone(templates)
        self.assertTrue(len(templates) > 0)
        self.assertTrue(templates[0].otype == 'template')
        table = self.make_template_table(templates)
        template_id = 'global_As Measured'
        template = table[template_id]
        self.assertIsNotNone(template)
        self.assertEqual(template.id, template_id)

        update_data = template.input_data
        update_data["does_transform"] = True
        self.assertNotEqual(update_data['owner'], '*****@*****.**')
        update_data.pop('id')
        update_data.pop('owner')

        template = _update_template(template.id, update_data)
        self.assertIsNotNone(template)
        self.assertEqual(template.id, template_id)
        self.assertEqual(template.otype, 'template')
        self.assertTrue(template.does_transform)

        update_data = template.input_data
        update_data["does_transform"] = False
        self.assertNotEqual(update_data['owner'], '*****@*****.**')
        update_data.pop('id')
        update_data.pop('owner')

        template = _update_template(template.id, update_data)
        self.assertIsNotNone(template)
        self.assertEqual(template.id, template_id)
        self.assertEqual(template.otype, 'template')
        self.assertFalse(template.does_transform)
Example #4
0
 def _make_template_table(self):
     template_list = get_all_templates()
     table = {}
     for template in template_list:
         table[template.id] = template
     return table
Example #5
0
 def get_all(self):
     return get_all_templates()