  Violation of a noncontextuality inequality or the phenomenon referred to
`quantum contextuality' is a fundamental feature of quantum theory. In this
article, we derive a novel family of noncontextuality inequalities along with
their sum-of-squares decompositions in the simplest (odd-cycle)
sequential-measurement scenario capable to demonstrate Kochen-Specker
contextuality. The sum-of-squares decompositions allow us to obtain the maximal
quantum violation of these inequalities and a set of algebraic relations
necessarily satisfied by any state and measurements achieving it. With their
help, we prove that our inequalities can be used for self-testing of
three-dimensional quantum state and measurements. Remarkably, the presented
self-testing results rely on a single assumption about the measurement device
that is much weaker than the assumptions considered in Kochen-Specker
contextuality.
