Skip to content

Commit

Permalink
test defect species.from_dict
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsquires committed May 16, 2023
1 parent 28c8171 commit 9bc4e2c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_defect_species.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,36 @@ def test_from_dict_with_fixed_concentration(self):
100,
)

def test_as_dict(self):
# Setup for the test:
mock_charge_states = {
0: Mock(spec=DefectChargeState),
1: Mock(spec=DefectChargeState),
2: Mock(spec=DefectChargeState),
}
mock_charge_states[0].as_dict.return_value = {"charge": 0}
mock_charge_states[1].as_dict.return_value = {"charge": 1}
mock_charge_states[2].as_dict.return_value = {"charge": 2}

self.defect_species._charge_states = mock_charge_states
self.defect_species._name = "v_O"
self.defect_species._nsites = 2
self.defect_species._fixed_concentration = 0.1234

# Call the method and get the result
result = self.defect_species.as_dict()

# Expected result
expected_result = {
"name": "v_O",
"nsites": 2,
"charge_states": {0: {"charge": 0}, 1: {"charge": 1}, 2: {"charge": 2}},
"fixed_concentration": 0.1234,
}

# Verify the result
self.assertEqual(result, expected_result)

def test__from_string(self):
string = "V_O 1 2\n2 2 2"
string = string.splitlines()
Expand Down

0 comments on commit 9bc4e2c

Please sign in to comment.