def test_standard_convert_str_to_bit(self, method_code): """Test conversion from string code to bit for standard cases""" self.ref_code = method_code self.set_c_code() self.out = aacgmv2.convert_str_to_bit(method_code) np.testing.assert_equal(self.out, self.c_method_code)
def test_convert_str_to_bit(self, method_code): """Test conversion from string code to bit""" if hasattr(aacgmv2._aacgmv2, method_code.upper()): self.c_method_code = getattr(aacgmv2._aacgmv2, method_code.upper()) else: raise ValueError('cannot find method in C code: {:}'.format( method_code)) assert aacgmv2.convert_str_to_bit(method_code) == self.c_method_code
def test_convert_str_to_bit_invalid(self): """Test conversion from string code to bit for an invalid code""" if aacgmv2.convert_str_to_bit("ggoogg|") != aacgmv2._aacgmv2.G2A: raise AssertionError()
def test_convert_str_to_bit_spaces(self): """Test conversion from string code to bit for a code with spaces""" if(aacgmv2.convert_str_to_bit("G2A | trace") != aacgmv2._aacgmv2.G2A + aacgmv2._aacgmv2.TRACE): raise AssertionError()
def test_convert_str_to_bit_lowercase(self): """Test conversion from string code to bit for a lowercase code""" if aacgmv2.convert_str_to_bit("g2a") != aacgmv2._aacgmv2.G2A: raise AssertionError()
def test_convert_str_to_bit_geocentric(self): """Test conversion from string code to bit GEOCENTRIC""" if(aacgmv2.convert_str_to_bit("GEOCENTRIC") != aacgmv2._aacgmv2.GEOCENTRIC): raise AssertionError()
def test_convert_str_to_bit_badidea(self): """Test conversion from string code to bit BADIDEA""" if(aacgmv2.convert_str_to_bit("BADIDEA") != aacgmv2._aacgmv2.BADIDEA): raise AssertionError()
def test_convert_str_to_bit_allowtrace(self): """Test conversion from string code to bit ALLOWTRACE""" if(aacgmv2.convert_str_to_bit("ALLOWTRACE") != aacgmv2._aacgmv2.ALLOWTRACE): raise AssertionError()
def test_convert_str_to_bit_trace(self): """Test conversion from string code to bit TRACE""" if aacgmv2.convert_str_to_bit("TRACE") != aacgmv2._aacgmv2.TRACE: raise AssertionError()
def test_convert_str_to_bit_a2g(self): """Test conversion from string code to bit A2G""" if aacgmv2.convert_str_to_bit("A2G") != aacgmv2._aacgmv2.A2G: raise AssertionError()
def test_convert_str_to_bit_g2a(self): """Test conversion from string code to bit G2A""" if aacgmv2.convert_str_to_bit("G2A") != aacgmv2._aacgmv2.G2A: raise AssertionError()
def test_non_standard_convert_str_to_bit(self, str_code, bit_ref): """Test conversion from string code to bit for non-standard cases""" self.out = aacgmv2.convert_str_to_bit(str_code) np.testing.assert_equal(self.out, bit_ref)