def test_cannot_add_query_parameter_first(self):
     r = RESTQuery()
     with pytest.raises(AssertionError) as e:
         r.add_query_parameter("AND", "sys_id", "EQUALS",
                               "546565465e4f654efewfweefeewz")
     assert "No query parameters have been specified yet. Use the ``Required Query Parameter Is`` keyword first." in str(
         e)
 def test_is_empty_query_required_if_no_params(self):
     r = RESTQuery()
     with pytest.raises(AssertionError) as e:
         r.required_query_parameter_is("my_field", "equals")
     assert "Unexpected arguments for condition type EQUALS: expected 1 or 2 arguments, but got none." in str(
         e)
     r.required_query_parameter_is(field="sys_id",
                                   condition_type="EQUALS",
                                   param_1="ehe876387364nkje")
     with pytest.raises(AssertionError) as e:
         r.add_query_parameter("AND", "my_field", "greater than")
     assert "Unexpected arguments for condition type GREATER THAN: expected 1 or 2 arguments, but got none." in str(
         e)
 def test_required_query_parameter_is_date_field(self):
     r = RESTQuery()
     r.query_table_is("incident")
     try:
         r.required_query_parameter_is("sys_created_on",
                                       "BETWEEN",
                                       "2016-05-02 09:45:01",
                                       "2016-05-09 09:45:01",
                                       is_date_field=True)
         r.add_query_parameter("OR", "sys_updated_on", "EQUALS",
                               "2018-08-10 10:23:40")
     except AssertionError:
         pytest.fail(
             "Unexpected AssertionError raised when setting date field query parameter."
         )
 def test_invalid_query_condition_type(self):
     r = RESTQuery()
     with pytest.raises(AssertionError) as e:
         r.required_query_parameter_is(field="sys_id",
                                       condition_type="INVALID",
                                       param_1="ehe876387364nkje")
     assert "Invalid condition type specified." in str(e)
     r.required_query_parameter_is(field="sys_id",
                                   condition_type="EQUALS",
                                   param_1="ehe876387364nkje")
     with pytest.raises(AssertionError) as e:
         r.add_query_parameter("INVALID",
                               field="number",
                               condition_type="EQUALS",
                               param_1="TKT546259")
     assert "Invalid operand" in str(e)
 def test_add_parameter_with_nq(self):
     r = RESTQuery()
     r.required_query_parameter_is("description", "CONTAINS", "michael")
     r.add_query_parameter("NQ", "status", "EQUALS", "Open")
     assert r.query._query[-2] == "^NQ"