Esempio n. 1
0
 def setUp(self):
     call_command_with_output("initdevice", "MyCentralDevice", "")
     self.zone = Zone.objects.create(name="MyZone")
     key = crypto.Key()
     self.remote_device = Device.objects.create(name="RemoteDevice", public_key=key.get_public_key_string())
     self.remote_device.key = key
     self.device_zone = DeviceZone.objects.create(zone=self.zone, device=self.remote_device)
     self.facility = Facility.objects.create(name="MyFacility")
     self.facility.sign(device=self.remote_device)
     self.facility.save(imported=True)
Esempio n. 2
0
 def test_no_options(self):
     try:
         (out, err, rc) = call_command_with_output('createmodel', 'some.model')
         self.assertFail()
     except CommandError as e:
         self.assertRegexpMatches(str(e),
                                  "Please specify input data as a json string")
Esempio n. 3
0
 def test_no_options(self):
     try:
         (out, err, rc) = call_command_with_output('readmodel', 'some.model')
         self.assertFail()
     except CommandError as e:
         self.assertRegexpMatches(str(e),
                                  "Please specify --id to fetch model.")
 def test_no_args(self):
     try:
         (out, err, rc) = call_command_with_output('readmodel')
         self.assertFail()
     except CommandError as e:
         self.assertRegexpMatches(str(e),
                                  "Please specify model class name.")
 def test_no_options(self):
     try:
         (out, err, rc) = call_command_with_output('readmodel',
                                                   'some.model')
         self.assertFail()
     except CommandError as e:
         self.assertRegexpMatches(str(e),
                                  "Please specify --id to fetch model.")
 def test_no_options(self):
     try:
         (out, err, rc) = call_command_with_output('createmodel',
                                                   'some.model')
         self.assertFail()
     except CommandError as e:
         self.assertRegexpMatches(
             str(e), "Please specify input data as a json string")
Esempio n. 7
0
    def test_fetch_model(self):
        MODEL_NAME = 'kalite.facility.models.Facility'
        facility_name = 'kir1'
        # Create a Facility object first that will be fetched.
        facility = Facility(name=facility_name)
        facility.save()

        (out, err, rc) = call_command_with_output('readmodel',
                                                  MODEL_NAME,
                                                  id=facility.id)
        data_map = json.loads(out)
        self.assertEquals(data_map['name'], facility_name)
Esempio n. 8
0
    def test_save_model(self):
        MODEL_NAME = 'kalite.facility.models.Facility'
        (out, err, rc) = call_command_with_output('createmodel',
                                                  MODEL_NAME,
                                                  json_data='{"name" : "kir1"}')
        self.assertEquals(rc, 0)
        module_path, model_name = MODEL_NAME.rsplit(".", 1)
        module = importlib.import_module(module_path)
        model = getattr(module, model_name)

        data = model.objects.get(pk=out.strip())
        self.assertEquals(data.name, "kir1")
    def test_fetch_model(self):
        MODEL_NAME = 'kalite.facility.models.Facility'
        facility_name = 'kir1'
        # Create a Facility object first that will be fetched.
        facility = Facility(name=facility_name)
        facility.save()

        (out, err, rc) = call_command_with_output('readmodel',
                                                  MODEL_NAME,
                                                  id=facility.id)
        data_map = json.loads(out)
        self.assertEquals(data_map['name'], facility_name)
    def test_save_model(self):
        MODEL_NAME = 'kalite.facility.models.Facility'
        (out, err,
         rc) = call_command_with_output('createmodel',
                                        MODEL_NAME,
                                        json_data='{"name" : "kir1"}')
        self.assertEquals(rc, 0)
        module_path, model_name = MODEL_NAME.rsplit(".", 1)
        module = importlib.import_module(module_path)
        model = getattr(module, model_name)

        data = model.objects.get(pk=out.strip())
        self.assertEquals(data.name, "kir1")
Esempio n. 11
0
 def test_no_args(self):
     try:
         (out, err, rc) = call_command_with_output('readmodel')
         self.assertFail()
     except CommandError as e:
         self.assertRegexpMatches(str(e), "Please specify model class name.")
Esempio n. 12
0
 def test_no_args(self):
     try:
         (out, err, rc) = call_command_with_output('createmodel')
         self.assertFail()
     except CommandError as e:
         self.assertRegexpMatches(str(e), "No args specified")
 def test_no_args(self):
     try:
         (out, err, rc) = call_command_with_output('createmodel')
         self.assertFail()
     except CommandError as e:
         self.assertRegexpMatches(str(e), "No args specified")